package net.genebase.elements;

import java.util.Random;

public class IntegerElement implements Mutatable<Integer>{

	Integer value;
	
	public IntegerElement(Integer d) {
		this.value = d;
	}

	@Override
	public Mutatable<Integer> mutate() {
		this.value = ((new Random()).nextInt(100));
		return this;
	}

	@Override
	public Mutatable<Integer> elementCrossover(Mutatable<Integer> element2) {
		int sum = this.value + element2.getData();
		return new IntegerElement(Math.round((sum/2.0f)));
	}

	@Override
	public Integer getData() {
		return value;
	}
	
	@Override
	public String toString(){
		return "" + this.value;
	}

	@Override
	public Mutatable<Integer> clone(){
		return new IntegerElement(this.value);
	}
}
